import Web3 from 'web3'
import { WEB3_PROVIDER_HTTPS } from 'configs'

const rpcUrl = WEB3_PROVIDER_HTTPS

const getProvider = (url) => {
  if (!url) {
    url = rpcUrl
  }
  return new Web3.providers.HttpProvider(url)
}

const getWebsocketProvider = (url) => {
  if (!url) {
    return new Web3.providers.WebsocketProvider(url)
  }
}

const getWeb3 = (provider) => {
  if (!provider) {
    provider = getProvider()
  }
  return new Web3(provider)
}
export { getWeb3, getProvider, getWebsocketProvider }
